

import Foundation
import UIKit

@objcMembers class FYModelTypeUtil: NSObject {
    
    class func fy_getMobileDeviceModelType() -> String {
        var deviceMachine = ""
        var mobileModelType = ""

        var systemInfo = utsname()
        uname(&systemInfo)
        deviceMachine = withUnsafePointer(to: &systemInfo.machine) {
            $0.withMemoryRebound(to: CChar.self, capacity: 1) {
                String(cString: $0)
            }
        }
        mobileModelType = deviceMachine

        if deviceMachine == "i386" || deviceMachine == "x86_64" || deviceMachine == "arm64" {
            mobileModelType = "iPhone Simulator"
        }
        
        if deviceMachine == "iPad1,1" {
            mobileModelType = "iPad"
        } else if deviceMachine == "iPad2,1" || deviceMachine == "iPad2,2" || deviceMachine == "iPad2,3" || deviceMachine == "iPad2,4" {
            mobileModelType = "iPad 2"
        } else if deviceMachine == "iPad2,5" || deviceMachine == "iPad2,6" || deviceMachine == "iPad2,7" {
            mobileModelType = "iPad mini"
        } else if deviceMachine == "iPad3,1" || deviceMachine == "iPad3,2" || deviceMachine == "iPad3,3" {
            mobileModelType = "iPad 3"
        } else if deviceMachine == "iPad3,4" || deviceMachine == "iPad3,5" || deviceMachine == "iPad3,6" {
            mobileModelType = "iPad 4"
        } else if deviceMachine == "iPad4,1" || deviceMachine == "iPad4,2" || deviceMachine == "iPad4,3" {
            mobileModelType = "iPad Air"
        } else if deviceMachine == "iPad4,4" || deviceMachine == "iPad4,5" || deviceMachine == "iPad4,6" {
            mobileModelType = "iPad mini 2"
        } else if deviceMachine == "iPad4,7" || deviceMachine == "iPad4,8" || deviceMachine == "iPad4,9" {
            mobileModelType = "iPad mini 3"
        } else if deviceMachine == "iPad5,1" || deviceMachine == "iPad5,2" {
            mobileModelType = "iPad mini 4"
        } else if deviceMachine == "iPad11,1" || deviceMachine == "iPad11,2" {
            mobileModelType = "iPad mini 5"
        } else if deviceMachine == "iPad14,1" || deviceMachine == "iPad14,2" {
            mobileModelType = "iPad mini 6"
        } else if deviceMachine == "iPad5,3" || deviceMachine == "iPad5,4" {
            mobileModelType = "iPad Air 2"
        } else if deviceMachine == "iPad6,3" || deviceMachine == "iPad6,4" {
            mobileModelType = "iPad Pro (9.7-inch)"
        } else if deviceMachine == "iPad6,7" || deviceMachine == "iPad6,8" {
            mobileModelType = "iPad Pro (12.9-inch)"
        } else if deviceMachine == "iPad6,11" || deviceMachine == "iPad6,12" {
            mobileModelType = "iPad 5"
        } else if deviceMachine == "iPad7,1" || deviceMachine == "iPad7,2" {
            mobileModelType = "iPad Pro 2 (12.9-inch)"
        } else if deviceMachine == "iPad7,3" || deviceMachine == "iPad7,4" {
            mobileModelType = "iPad Pro (10.5-inch)"
        } else if deviceMachine == "iPad7,5" || deviceMachine == "iPad7,6" {
            mobileModelType = "iPad 6"
        } else if deviceMachine == "iPad7,11" || deviceMachine == "iPad7,12" {
            mobileModelType = "iPad 7"
        } else if deviceMachine == "iPad11,6" || deviceMachine == "iPad11,7" {
            mobileModelType = "iPad 8"
        } else if deviceMachine == "iPad12,1" || deviceMachine == "iPad12,2" {
            mobileModelType = "iPad 9"
        } else if deviceMachine == "iPad11,3" || deviceMachine == "iPad11,4" {
            mobileModelType = "iPad Air 3"
        } else if deviceMachine == "iPad13,1" || deviceMachine == "iPad13,2" {
            mobileModelType = "iPad Air 4"
        } else if deviceMachine == "iPad13,16" || deviceMachine == "iPad13,17" {
            mobileModelType = "iPad Air 5"
        } else if deviceMachine == "iPad8,1" || deviceMachine == "iPad8,2" || deviceMachine == "iPad8,3" || deviceMachine == "iPad8,4" {
            mobileModelType = "iPad Pro (11-inch)"
        } else if deviceMachine == "iPad8,5" || deviceMachine == "iPad8,6" || deviceMachine == "iPad8,7" || deviceMachine == "iPad8,8" {
            mobileModelType = "iPad Pro 3 (12.9-inch)"
        } else if deviceMachine == "iPad8,9" || deviceMachine == "iPad8,10" {
            mobileModelType = "iPad Pro 2 (11-inch)"
        } else if deviceMachine == "iPad8,11" || deviceMachine == "iPad8,12" {
            mobileModelType = "iPad Pro 4 (12.9-inch)"
        } else if deviceMachine == "iPad13,4" || deviceMachine == "iPad13,5" || deviceMachine == "iPad13,6" || deviceMachine == "iPad13,7" {
            mobileModelType = "iPad Pro 3 (11-inch)"
        } else if deviceMachine == "iPad13,8" || deviceMachine == "iPad13,9" || deviceMachine == "iPad13,10" || deviceMachine == "iPad13,11" {
            mobileModelType = "iPad Pro 5 (12.9-inch)"
        } else if deviceMachine.hasPrefix("iPad") {
            mobileModelType = "iPad"
        }

        else if deviceMachine == "iPhone7,1" {
            mobileModelType = "iPhone 6 Plus"
        } else if deviceMachine == "iPhone7,2" {
            mobileModelType = "iPhone 6"
        } else if deviceMachine == "iPhone8,1" {
            mobileModelType = "iPhone 6s"
        } else if deviceMachine == "iPhone8,2" {
            mobileModelType = "iPhone 6s Plus"
        } else if deviceMachine == "iPhone8,4" {
            mobileModelType = "iPhone SE"
        } else if deviceMachine == "iPhone9,1" || deviceMachine == "iPhone9,3" {
            mobileModelType = "iPhone 7"
        } else if deviceMachine == "iPhone9,2" || deviceMachine == "iPhone9,4" {
            mobileModelType = "iPhone 7 Plus"
        } else if deviceMachine == "iPhone10,1" || deviceMachine == "iPhone10,4" {
            mobileModelType = "iPhone 8"
        } else if deviceMachine == "iPhone10,2" || deviceMachine == "iPhone10,5" {
            mobileModelType = "iPhone 8 Plus"
        } else if deviceMachine == "iPhone10,3" || deviceMachine == "iPhone10,6" {
            mobileModelType = "iPhone X"
        } else if deviceMachine == "iPhone11,8" {
            mobileModelType = "iPhone XR"
        } else if deviceMachine == "iPhone11,2" {
            mobileModelType = "iPhone XS"
        } else if deviceMachine == "iPhone11,6" {
            mobileModelType = "iPhone XS Max"
        } else if deviceMachine == "iPhone12,1" {
            mobileModelType = "iPhone 11"
        } else if deviceMachine == "iPhone12,3" {
            mobileModelType = "iPhone 11 Pro"
        } else if deviceMachine == "iPhone12,5" {
            mobileModelType = "iPhone 11 Pro Max"
        } else if deviceMachine == "iPhone12,8" {
            mobileModelType = "iPhone SE 2"
        } else if deviceMachine == "iPhone13,1" {
            mobileModelType = "iPhone 12 mini"
        } else if deviceMachine == "iPhone13,2" {
            mobileModelType = "iPhone 12"
        } else if deviceMachine == "iPhone13,3" {
            mobileModelType = "iPhone 12 Pro"
        } else if deviceMachine == "iPhone13,4" {
            mobileModelType = "iPhone 12 Pro Max"
        } else if deviceMachine == "iPhone14,4" {
            mobileModelType = "iPhone 13 mini"
        } else if deviceMachine == "iPhone14,5" {
            mobileModelType = "iPhone 13"
        } else if deviceMachine == "iPhone14,2" {
            mobileModelType = "iPhone 13 Pro"
        } else if deviceMachine == "iPhone14,3" {
            mobileModelType = "iPhone 13 Pro Max"
        } else if deviceMachine == "iPhone14,6" {
            mobileModelType = "iPhone SE 3"
        } else if deviceMachine == "iPhone14,7" {
            mobileModelType = "iPhone 14"
        } else if deviceMachine == "iPhone14,8" {
            mobileModelType = "iPhone 14 Plus"
        } else if deviceMachine == "iPhone15,2" {
            mobileModelType = "iPhone 14 Pro"
        } else if deviceMachine == "iPhone15,3" {
            mobileModelType = "iPhone 14 Pro Max"
        } else if deviceMachine == "iPhone15,4" {
            mobileModelType = "iPhone 15"
        } else if deviceMachine == "iPhone15,5" {
            mobileModelType = "iPhone 15 Plus"
        } else if deviceMachine == "iPhone16,1" {
            mobileModelType = "iPhone 15 Pro"
        } else if deviceMachine == "iPhone16,2" {
            mobileModelType = "iPhone 15 Pro Max"
        } else if deviceMachine == "iPhone17,3" {
            mobileModelType = "iPhone 16"
        } else if deviceMachine == "iPhone17,4" {
            mobileModelType = "iPhone 16 Plus"
        } else if deviceMachine == "iPhone17,1" {
            mobileModelType = "iPhone 16 Pro"
        } else if deviceMachine == "iPhone17,2" {
            mobileModelType = "iPhone 16 Pro Max"
        } else if deviceMachine == "iPhone17,5" {
            mobileModelType = "iPhone 16 e"
        } else if deviceMachine == "iPhone18,1" {
            mobileModelType = "iPhone 17 Pro"
        } else if deviceMachine == "iPhone18,2" {
            mobileModelType = "iPhone 17 Pro Max"
        } else if deviceMachine == "iPhone18,3" {
            mobileModelType = "iPhone 17"
        } else if deviceMachine == "iPhone18,4" {
            mobileModelType = "iPhone Air"
        }
        return mobileModelType
    }
}



